#ifndef MSGSOCKET_H
#define MSGSOCKET_H

#include <QThread>
#include <QTcpSocket>

class MsgSocket : public QThread
{
    Q_OBJECT

signals:
    void signalUserLoginResult(bool res);
    void signalUserLogoutResult(bool res);
    void signalAppengChatMsg(QString name, QString role, QString msg);

    ///解析设备控制命令
    void signalparseDevTemp(QString data);
    void signalparseDevHumi(QString data);
    void signalparseDevMode(QString data);
    void signalparseDevStat(QString data);

public slots:
    void slotReadyRead();
    void slotSendMsg(QString msg);

public:
    explicit MsgSocket(QThread *parent = 0);
    ~MsgSocket();

    void exitThread(void);

protected:
    void run();

private:
    bool m_isExit;
    quint16 m_tcpBlockSize;
    QTcpSocket *m_tcpSocket;

    void parseUserAsk(QString msg);
    ///通用请求命令 - 登录退出在MsgSocket中实现
    void parseUserLogin(QString data);
    void parseChangePswd(QString data);
    void parseHomeChat(QString data);
//    void parseUserExit(QString data);
};

#endif // MSGSOCKET_H
